package com.example.design.结构型设计模式.组合模式;

public class CombinationMain {
    public static void main(String[] args) {
        MenuComponent appetizerMenu = new MenuGroup("Appetizers");
        MenuComponent mainCourseMenu = new MenuGroup("Main Courses");
        MenuComponent dessertMenu = new MenuGroup("Desserts");

        MenuComponent allMenus = new MenuGroup("Complete Menu");
        allMenus.add(appetizerMenu);
        allMenus.add(mainCourseMenu);
        allMenus.add(dessertMenu);

        // 添加具体菜品
        appetizerMenu.add(new MenuItem("Bruschetta", 5.99));
        appetizerMenu.add(new MenuItem("Garlic Bread", 3.99));

        mainCourseMenu.add(new MenuItem("Grilled Chicken", 14.99));
        mainCourseMenu.add(new MenuItem("Spaghetti Carbonara", 12.99));

        dessertMenu.add(new MenuItem("Tiramisu", 6.99));
        dessertMenu.add(new MenuItem("Cheesecake", 5.49));

        // 打印整个菜单
        allMenus.print();
    }
}